﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;

namespace Dmo_lc_2.Shape
{
    public class LineShape : BaseShape
    {
        public double[] startPos ;
        public double[] endPos;

        public LineShape(Entity in_entity, Transaction tr) : base(in_entity, tr)
        {
        }

        public int weight { get; set; }

        public override void Init()
        {
            Line in_line = (Line)mEntity;

            ObjectId lineTypeId = in_line.LinetypeId;
            shapeType = ShapeType.LINE;
            shapeTypeName = shapeType.ToString();

            color = getColor();
            startPos = new double[] { in_line.StartPoint.X, in_line.StartPoint.Y, in_line.StartPoint.Z };
            endPos = new double[] { in_line.EndPoint.X, in_line.EndPoint.Y, in_line.EndPoint.Z };
            weight = (int)in_line.LineWeight;


            LinetypeTableRecord lineType = mTransaction.GetObject(mEntity.LinetypeId, OpenMode.ForRead) as LinetypeTableRecord;
            string lineTypeName = lineType.Name;
            string lineTypeIDesc = lineType.AsciiDescription;
            double patternLength = lineType.PatternLength;
            int numDashes= lineType.NumDashes;

            for (int i = 0; i < numDashes; i++) {
                double dashLength = lineType.DashLengthAt(i);
                ObjectId shapeStyle = lineType.ShapeStyleAt(i);

                Console.WriteLine(dashLength);
            }

        }
    }
}